home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / netinfo / ni_prot.x < prev    next >
Text File  |  1991-08-07  |  9KB  |  479 lines

  1. /* 
  2.  * NetInfo protocol specification
  3.  * Copyright (C) 1989 by NeXT, Inc.
  4.  */
  5.  
  6. /* Preamble appearing on all generated output */
  7. #ifndef NOPREAMBLE
  8. %/*
  9. % * Output of the RPC protocol compiler: DO NOT EDIT
  10. % * Copyright (C) 1989 by NeXT, Inc.
  11. % */
  12. #endif
  13.  
  14. #ifndef RPC_HDR
  15. %#include <stdio.h>
  16. %#include <sys/time.h>
  17. %#include "clib.h"
  18. #endif
  19. const NI_NAME_MAXLEN = 65535;
  20. const NI_NAMELIST_MAXLEN = 65535;
  21. const NI_PROPLIST_MAXLEN = 65535;
  22. const NI_IDLIST_MAXLEN = 1048576;
  23.  
  24. /*
  25.  * Every object has a unique ID. One part of the ID identifies the object
  26.  * itself. The other identifies the instance of the object. Every time
  27.  * an object is written or an object is destroyed and then reallocated, 
  28.  * its instance is incremented. 
  29.  *
  30.  * All read operations ignore the instance field. All write operations 
  31.  * refuse to operate on the object if there is an instance mismatch.
  32.  */
  33.  
  34. /*
  35.  * Don't go through unnecessary overhead for xdr_ni_index using typedef
  36.  * rpcgen needs an optimizer so we don't have to do this!
  37.  */
  38. #ifdef RPC_HDR
  39. %typedef unsigned long ni_index;
  40. #endif
  41. #define ni_index unsigned long
  42.  
  43. struct ni_id {
  44.     ni_index nii_object;
  45.     ni_index nii_instance;
  46. };
  47.  
  48.  
  49. /*
  50.  * Names are assumed to contain human-readable ASCII characters.
  51.  */
  52. typedef string ni_name<NI_NAME_MAXLEN>;
  53.  
  54.  
  55. typedef ni_name ni_namelist<NI_NAMELIST_MAXLEN>;
  56.  
  57. /*
  58.  * A property
  59.  */
  60. struct ni_property {
  61.     ni_name nip_name;
  62.     ni_namelist nip_val;
  63. };
  64.  
  65. /*
  66.  * A list of properties
  67.  */
  68. typedef ni_property ni_proplist<NI_PROPLIST_MAXLEN>;
  69.  
  70. /*
  71.  * A list of IDs (yet another variable-length array)
  72.  */
  73. typedef ni_index ni_idlist<NI_IDLIST_MAXLEN>;
  74.  
  75.  
  76. /*
  77.  * A name object
  78.  */
  79. struct ni_object {
  80.     ni_id nio_id;
  81.     ni_proplist nio_props;
  82.     ni_index nio_parent;
  83.     ni_idlist nio_children;
  84. };
  85.  
  86.  
  87. /*
  88.  * All operations return a status indicating either that the requested 
  89.  * operation succeeded or why it failed.
  90.  */
  91. enum ni_status {
  92.     NI_OK,        /* Operation succeeded */
  93.     NI_BADID,    /* ID is invalid */
  94.     NI_STALE,    /* Write attempted on stale version of object */
  95.     NI_NOSPACE,    /* No space available for write operation */
  96.     NI_PERM,    /* Permission denied */
  97.     NI_NODIR,    /* No such directory */
  98.     NI_NOPROP,    /* No such property */
  99.     NI_NONAME,    /* No such name */
  100.     NI_NOTEMPTY,    /* Cannot delete name object with children */
  101.     NI_UNRELATED,    /* Object is not child of parent: cannot destroy */
  102.     NI_SERIAL,    /* Serialization error */
  103.     NI_NETROOT,    /* Hit network root directory */
  104.     NI_NORESPONSE,    /* No response from remote parent */
  105.     NI_RDONLY,    /* No writes allowed: all objects are read-only */
  106.     NI_SYSTEMERR,    /* generic remote error */
  107.     NI_ALIVE,    /* Can't regenerate: already in use */
  108.     NI_NOTMASTER,    /* Operation makes no sense on clone */
  109.     NI_CANTFINDADDRESS, /* Can't find address of server */
  110.     NI_DUPTAG,    /* Duplicate domain tag: can't serve it */
  111.     NI_NOTAG,    /* No such tag */
  112.     NI_AUTHERROR,    /* Authentication error */
  113.     NI_NOUSER,    /* No such user */
  114.     NI_MASTERBUSY,    /* Master server is busy */
  115.     NI_FAILED = 9999    /* generic local error */
  116. };
  117.  
  118. /*
  119.  * Wrappers needed to handle arguments and results
  120.  */
  121. union ni_id_res switch (ni_status status) {
  122. case NI_OK:
  123.     ni_id id;
  124. default:
  125.     void;
  126. };
  127.  
  128. struct ni_parent_stuff {
  129.     ni_index object_id;
  130.     ni_id self_id;
  131. };
  132.  
  133. union ni_parent_res switch (ni_status status) {
  134. case NI_OK:
  135.     struct ni_parent_stuff stuff;
  136. default:
  137.     void;
  138. };
  139.  
  140. struct ni_children_stuff {
  141.     ni_idlist children;
  142.     ni_id self_id;
  143. };
  144.  
  145. union ni_children_res switch (ni_status status) {
  146. case NI_OK:
  147.     ni_children_stuff stuff;
  148. default:
  149.     void;
  150. };
  151.  
  152. struct ni_entry {
  153.     ni_index id;
  154.     ni_namelist *names;
  155. };
  156.  
  157. typedef ni_entry ni_entrylist<NI_IDLIST_MAXLEN>;
  158.  
  159. struct ni_list_stuff {
  160.     ni_entrylist entries;
  161.     ni_id self_id;
  162. };
  163.  
  164. union ni_list_res switch (ni_status status) {
  165. case NI_OK:
  166.     ni_list_stuff stuff;
  167. default:
  168.     void;
  169. };
  170.  
  171. struct ni_proplist_stuff {
  172.     ni_id id;
  173.     ni_proplist props;
  174. };
  175.  
  176. struct ni_create_args {
  177.     ni_id id;
  178.     ni_proplist props;
  179.     ni_index where;
  180.     ni_id *target_id;
  181. };
  182.  
  183. union ni_proplist_res switch (ni_status status) {
  184. case NI_OK:
  185.     ni_proplist_stuff stuff;
  186. default:
  187.     void;
  188. };
  189.     
  190. struct ni_create_stuff {
  191.     ni_id id;
  192.     ni_id self_id;
  193. };
  194.  
  195. union ni_create_res switch (ni_status status) {
  196. case NI_OK:
  197.     ni_create_stuff stuff;
  198. default:
  199.     void;
  200. };
  201.  
  202. struct ni_destroy_args {
  203.     ni_id parent_id;
  204.     ni_id self_id;
  205. };
  206.  
  207. struct ni_lookup_args {
  208.     ni_id id;
  209.     ni_name key;
  210.     ni_name value;
  211. };
  212.  
  213. struct ni_lookup_stuff {
  214.     ni_idlist idlist;
  215.     ni_id self_id;
  216. };
  217.  
  218. union ni_lookup_res switch (ni_status status) {
  219. case NI_OK:
  220.     ni_lookup_stuff stuff;
  221. default:
  222.     void;
  223. };
  224.  
  225.  
  226. struct ni_name_args {
  227.     ni_id id;
  228.     ni_name name;
  229. };
  230.  
  231. struct ni_createprop_args {
  232.     ni_id id;
  233.     ni_property prop;
  234.     ni_index where;
  235. };
  236.  
  237. struct ni_writeprop_args {
  238.     ni_id id;
  239.     ni_index prop_index;
  240.     ni_namelist values;
  241. };
  242.  
  243. struct ni_prop_args {
  244.     ni_id id;
  245.     ni_index prop_index;
  246. };
  247.  
  248. struct ni_namelist_stuff {
  249.     ni_namelist values;
  250.     ni_id self_id;
  251. };
  252.  
  253. union ni_namelist_res switch (ni_status status) {
  254. case NI_OK:
  255.     ni_namelist_stuff stuff;
  256. default:
  257.     void;
  258. };
  259.  
  260. struct ni_propname_args {
  261.     ni_id id;
  262.     ni_index prop_index;
  263.     ni_name name;
  264. };
  265.  
  266. struct ni_createname_args {
  267.     ni_id id;
  268.     ni_index prop_index;
  269.     ni_name name;
  270.     ni_index where;
  271. };
  272.  
  273. struct ni_nameindex_args {
  274.     ni_id id;
  275.     ni_index prop_index;
  276.     ni_index name_index;
  277. };
  278.  
  279. struct ni_writename_args {
  280.     ni_id id;
  281.     ni_index prop_index;
  282.     ni_index name_index;
  283.     ni_name name;
  284. };
  285.  
  286. struct ni_readname_stuff {
  287.     ni_id id;
  288.     ni_name name;
  289. };
  290.  
  291. union ni_readname_res switch (ni_status status) {
  292. case NI_OK:
  293.     ni_readname_stuff stuff;
  294. default:
  295.     void;
  296. };
  297.  
  298. struct ni_binding {
  299.     ni_name tag;
  300.     unsigned addr;
  301. };
  302.  
  303. union ni_rparent_res switch (ni_status status) {
  304. case NI_OK:
  305.     ni_binding binding;
  306. default:
  307.     void;
  308. };
  309.  
  310. typedef struct ni_object_node *ni_object_list;
  311. struct ni_object_node {
  312.     ni_object object;
  313.     ni_object_list next;
  314. };
  315.  
  316. struct ni_readall_stuff {
  317.     unsigned checksum;
  318.     ni_index highestid;
  319.     ni_object_list list;
  320. };
  321.     
  322. union ni_readall_res switch (ni_status status) {
  323. case NI_OK:
  324.     ni_readall_stuff stuff;
  325. default:
  326.     void;
  327. };
  328.  
  329. typedef ni_proplist ni_proplist_list<NI_IDLIST_MAXLEN>;
  330.  
  331. struct ni_listall_stuff {
  332.     ni_id self_id;
  333.     ni_proplist_list entries;
  334. };
  335.  
  336. union ni_listall_res switch (ni_status status) {
  337. case NI_OK:
  338.     ni_listall_stuff stuff;
  339. default:
  340.     void;
  341. };
  342.  
  343.  
  344. program NI_PROG {
  345.     version NI_VERS {
  346.         void
  347.         _NI_PING(void) = 0;
  348.         /*
  349.          * Get various server statistics
  350.          */
  351.         ni_proplist
  352.         _NI_STATISTICS(void) = 1;
  353.  
  354.         /*
  355.          * Procedures dealing with nodes
  356.          */
  357.         ni_id_res
  358.         _NI_ROOT(void) = 2;
  359.  
  360.         ni_id_res
  361.         _NI_SELF(ni_id) = 3;
  362.  
  363.         ni_parent_res
  364.         _NI_PARENT(ni_id) = 4;    
  365.  
  366.         ni_create_res
  367.         _NI_CREATE(ni_create_args) = 5;    
  368.  
  369.         ni_id_res
  370.         _NI_DESTROY(ni_destroy_args) = 6; 
  371.  
  372.         ni_proplist_res
  373.         _NI_READ(ni_id) = 7;
  374.  
  375.         ni_id_res
  376.         _NI_WRITE(ni_proplist_stuff) = 8;
  377.  
  378.         ni_children_res
  379.         _NI_CHILDREN(ni_id) = 9;
  380.  
  381.         ni_lookup_res
  382.         _NI_LOOKUP(ni_lookup_args) = 10; 
  383.  
  384.         ni_list_res
  385.         _NI_LIST(ni_name_args) = 11;
  386.  
  387.         /*
  388.          * Procedures dealing with properties
  389.          */
  390.         ni_id_res
  391.         _NI_CREATEPROP(ni_createprop_args) = 12; 
  392.         
  393.         ni_id_res
  394.         _NI_DESTROYPROP(ni_prop_args) = 13; 
  395.  
  396.         ni_namelist_res
  397.         _NI_READPROP(ni_prop_args) = 14;    
  398.  
  399.         ni_id_res
  400.         _NI_WRITEPROP(ni_writeprop_args) = 15;
  401.  
  402.         ni_id_res
  403.         _NI_RENAMEPROP(ni_propname_args) = 16;
  404.         
  405.         ni_namelist_res
  406.         _NI_LISTPROPS(ni_id) = 17;
  407.  
  408.         /*
  409.          * Procedures dealing with names
  410.          */
  411.         ni_id_res
  412.         _NI_CREATENAME(ni_createname_args) = 18;
  413.  
  414.         ni_id_res
  415.         _NI_DESTROYNAME(ni_nameindex_args) = 19;
  416.  
  417.         ni_readname_res
  418.         _NI_READNAME(ni_nameindex_args) = 20;
  419.  
  420.         ni_id_res
  421.         _NI_WRITENAME(ni_writename_args) = 21;
  422.  
  423.         /*
  424.          * Returns the address of this domain's remote parent
  425.          */
  426.         ni_rparent_res
  427.         _NI_RPARENT(void) = 22;
  428.  
  429.         /*
  430.          * List all properties of each subdirectory, not just
  431.          * just a single named property.
  432.          *
  433.          * WARNING: this routine is dangerous and may be
  434.          * removed from future implementations of the protocol.
  435.          * While it is good the the network in that there is
  436.          * less data on it because a lot is done in a single call, 
  437.          * it is bad for the server because it ties it up and locks 
  438.          * others out.
  439.          */
  440.         ni_listall_res
  441.         _NI_LISTALL(ni_id) = 23;
  442.  
  443.         /*
  444.          * Answers only if the given binding is served
  445.          */
  446.         void
  447.         _NI_BIND(ni_binding) = 24;
  448.         
  449.         /*
  450.          * Read the entire database if the checksum is different
  451.          * Implemented by master only.
  452.          */
  453.         ni_readall_res
  454.         _NI_READALL(unsigned) = 25;
  455.  
  456.         /*
  457.          * Informs server that master has crashed. Hands out
  458.          * latest checksum.
  459.          */
  460.         void
  461.         _NI_CRASHED(unsigned) = 26;
  462.  
  463.         /*
  464.          * If master, force clones to resync.
  465.          * If clone, resync with master.
  466.          */
  467.         ni_status
  468.         _NI_RESYNC(void) = 27; 
  469.  
  470.  
  471.         /*
  472.          * Extra procedure added for performance
  473.          * Terminates on first hit, returns proplist
  474.           */
  475.         ni_proplist_res
  476.         _NI_LOOKUPREAD(ni_lookup_args) = 28;
  477.     } = 2;
  478. } = 200100000;
  479.